--- Detailed specification of items to import or hide.
module frege.compiler.types.ImportDetails where 


import  frege.compiler.types.SNames

{--
    structure of an import list
--}
data ImportList = Imports {
        publik, except :: Bool,     -- kind of import list
        items :: [ImportItem]
    }


{--
    a single import item
--}
data ImportItem = Item {
        publik :: Bool,             -- re-export this one
        name :: SName,              -- to be resolved in the imported package
        members :: Maybe [ImportItem],    -- members
        alias :: String             -- guaranteed to be unqualified through syntax
    } where
        export :: ImportItem -> ImportItem
        export it = it.{publik = true, members <- fmap (map export)}


--- Prototype for an 'Item'
protoItem = Item { publik = false, name = protoSimple, members = Nothing, alias = "" }


--- 'ImportList' used when none is specified
linkAll  = Imports { publik = false, except = true,  items = [] }


--- 'ImportList' for ()
linkNone = Imports { publik = false, except = false, items = [] }


